<?php
namespace app\shop\home;

use app\shop\model\Banner;
use app\shop\model\Artwork;
use app\shop\model\Artist;
use app\shop\model\ArtworkGroup;

use app\admin\model\Attachment;
/**
 * 前台首页控制器
 */
class Index extends Common
{
    public function index()
    {
    	//轮播图
    	$banners =Banner::with('getimgpath')->where(['status'=>1,'group'=>1])->order('sort')->select();
    	//艺术品列表
    	$list = Artwork::with('getartist')->select();

        
        foreach ($list as $k => &$v) {
            $in = explode(',', $v['photos']);
//            pr($in,0);
            $ins = [];
            for($i = 0; $i <count($in); $i++){
//                echo $in[$i];
               $ins[] = Attachment::where('id',$in[$i])->value('path');
            }
             $v['img'] = $ins;
        }
//        pr($list);exit;
        //获取本期人物 暂时查两条
        $artist = Artist::limit(2)->with('getimgpath')->select();
        
        $user = session("auction_user");

    	
    	$this->assign('list', $list);
        $this->assign('artist', $artist);

        //$this->assign();
       
       if(isMobile()){
           $banners =Banner::with('getimgpath')->where(['status'=>1,'group'=>2])->order('sort')->select();
           $banners2 =Banner::with('getimgpath')->where(['status'=>1,'group'=>3])->order('sort')->select();
           $this->assign('banners', $banners);
           $this->assign('banners2', $banners2);
            return $this->fetch('Mobile/index/index');
//            return $this->fetch();
       }else{

           $this->assign('banners', $banners);
            return $this->fetch();
       }
        
    }
}